package com.jchen.system.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.github.pagehelper.PageInfo;
import com.jchen.common.entity.UserInfo;
import com.jchen.system.feign.UserFeign;
import com.jchen.system.service.IUserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description
 * @Author jchen
 * @Date 2023/12/7 14:21
 */
@Api(value = "用户管理",tags = "用户管理")
@RestController
@RequestMapping("/user")
public class UserInfoController {

    @Autowired
    private IUserInfoService userInfoService;

    /**
     * sentinel流控qps设置为1
     * @return
     */
    @ApiOperation("用户保存")
    @PostMapping("/saveUserInfo")
    //@SentinelResource(value = "saveUserInfoResource",blockHandler = "saveUserInfoHandler")
    public String saveUserInfo(@RequestBody UserInfo userInfo){
        return userInfoService.saveUserInfo(userInfo);
    }

    /**
     * sentinel流控qps设置为1
     * @return
     */
    @ApiOperation("用户分页查询")
    @GetMapping("/selectListPage/{pageNum}/{pageSize}")
    public PageInfo<UserInfo> selectListPage(@PathVariable int pageNum, @PathVariable int pageSize, UserInfo userInfo){
        return userInfoService.selectListPage(pageNum,pageSize,userInfo);
    }
}
